// 需要添加底部的页面
var footerList = [
  "home/list.html",
  "bookshelf/list.html",
  "discover/list.html",
  "my/my.html",
  // "login/login.html",
];

// 底部 tab 的下标
var footerIndex = 0;
// 是否需要添加底部
var needFooter = false;
footerList.forEach((item,index) => {
  // 如果地址栏存在于footerList数组, 就将needFooter设置为 true
  if(location.href.includes(item)){
    footerIndex = index;
    needFooter = true;
  }
});

var common = {
  rendFooter() {
    if (needFooter) {
      $("footer").html(`
                <a class="link ${footerIndex===0?'active':''} flex fdc aic jc-c f888" href="../home/list.html">
                    <i class="iconfont icon-huibenyuedu f22"></i>
                    <span class="pt-5 f12">绘本</span>
                </a>
                <a class="link ${footerIndex===1?'active':''} flex fdc aic jc-c f888" href="../bookshelf/list.html">
                    <i class="iconfont icon-wodeshujia f22"></i>
                    <span class="pt-5 f12">书架</span>
                </a>
                <a class="link ${footerIndex===2?'active':''} flex fdc aic jc-c f888" href="../discover/list.html">
                    <i class="iconfont icon-faxian f22"></i>
                    <span class="pt-5 f12">发现</span>
                </a>
                <a class="link ${footerIndex===3?'active':''} flex fdc aic jc-c f888" href="../my/my.html">
                    <i class="iconfont icon-gerenzhongxin f22"></i>
                    <span class="pt-5 f12">我的</span>
                </a>
            `);
    }
  },
};

common.rendFooter();
